// file: 	cs-alt-measures.do
// purpose: replace cs models with different measures of constituency size;
// 			model results reported in Table OA2-5; Figure OA2.



gen size_total = size_low + size_up

replace cssen =. if stateabv=="NE"
gen lncssen = ln(cssen)
gen lncsbicam = ln(csbicam)

bysort fips year: gen num=_n
pwcorr ln* size_low size_up cs* population if year==2010 & num==1
sum cssen cshouse csbicam size_low size_up if year==2010 & num==1




// CS Sen //
quietly meologit opst lncssen i.year ||fips:

	estimates store m1_b

quietly meologit opst lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m2_b

quietly meologit opst lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" ||fips:
	
estimates store m3_b
	
quietly meologit opst c.lnpop##c.size_up opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m4_b



* Single level, weighted
quietly ologit opst lncssen i.year [pw=weight] , cluster(fips)

	estimates store m1_b_wgt

quietly ologit opst lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year [pw=weight] , cluster(fips)
	
estimates store m2_b_wgt

quietly ologit opst lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" [pw=weight] , cluster(fips)
	
estimates store m3_b_wgt

quietly ologit opst c.lnpop##c.size_up opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year [pw=weight] , cluster(fips)
	
estimates store m4_b_wgt



// Make regression tables using esttab //

esttab m1_b_wgt m2_b_wgt m1_b m2_b using tableOA2_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncssen policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  replace
	
esttab m3_b_wgt m4_b_wgt m3_b m4_b using tableOA2_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncssen lnpop size_low c.lnpop#c.size_up policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  append
	

// CS Bicam //	

quietly meologit opst lncsbicam i.year ||fips:

	estimates store m1_c

quietly meologit opst lncsbicam opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m2_c	

quietly meologit opst lncsbicam opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" ||fips:
	
estimates store m3_c

quietly meologit opst c.lnpop##c.size_total opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m4_c

* Single level with weights

quietly ologit opst lncsbicam i.year [pw=weight] , cluster(fips)

	estimates store m1_c_wgt

quietly ologit opst lncsbicam opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year [pw=weight] , cluster(fips)
	
estimates store m2_c_wgt

quietly ologit opst lncsbicam opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" [pw=weight] , cluster(fips)
	
estimates store m3_c_wgt

quietly ologit opst c.lnpop##c.size_total opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year [pw=weight] , cluster(fips)
	
estimates store m4_c_wgt


// Make regression tables using esttab //

esttab m1_c_wgt m2_c_wgt m1_c m2_c using tableOA3_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncsbicam policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  replace
	
esttab m3_c_wgt m4_c_wgt m3_c m4_c using tableOA3_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncsbicam lnpop size_total c.lnpop#c.size_total policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  append

	
	
// CS both //	

quietly meologit opst lncs lncssen i.year ||fips:

	estimates store m1_d

quietly meologit opst lncs lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m2_d

quietly meologit opst lncs lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" ||fips:
	
estimates store m3_d

quietly meologit opst c.lnpop##c.size_low c.lnpop##c.size_up opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year ||fips:
	
estimates store m4_d


* Single level with weights

quietly ologit opst lncs lncssen i.year [pw=weight], cluster(fips)

estimates store m1_d_wgt

quietly ologit opst lncs lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year [pw=weight], cluster(fips)
	
estimates store m2_d_wgt
	
quietly ologit opst lncs lncssen opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs c.policy##c.partyid ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.unified_gov##c.partyid i.year if stateabv~="NH" & stateabv~="CA" [pw=weight], cluster(fips)
	
estimates store m3_d_wgt	
	
quietly ologit opst c.lnpop##c.size_low c.lnpop##c.size_up opfed c.percapincreal unemployment debt_net_pc_real pct_ba ///
	pct_black pct_hisp pct_rural mds1 mds2_abs h_diffs  ///
	r_male c.r_age##c.r_age r_educ r_hisp r_black ///
	c.hou_majority##c.partyid c.policy##c.partyid c.unified_gov##c.partyid i.year [pw=weight], cluster(fips)
	
estimates store m4_d_wgt


// Make regression tables using esttab //

esttab m1_d_wgt m2_d_wgt m1_d m2_d using tableOA4_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncs lncssen policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  replace
	
esttab m3_d_wgt m4_d_wgt m3_d m4_d using tableOA4_5.txt, cells("b(fmt(3) star) se(fmt(3) par)") ///
	starlevels(+ .1 * .05 ** .01) tex stats(N aic bic) style(tex) ///
	label nolz drop(199*.year 20*.year) ///
	order(lncs lncssen lnpop size_low c.lnpop#c.size_low c.lnpop#c.size_up policy unified_gov ///
	hou_majority h_diffs mds1 mds2_abs unemployment percapincreal debt_net_pc_real ///
	pct_ba pct_black pct_hisp pct_rural opfed partyid c.policy#c.partyid c.unified_gov#c.partyid ///
	c.hou_majority#c.partyid  ///
	r_male r_educ r_age c.r_age#c.r_age r_black r_hisp)  append	
		
